package Atomic;

public class BankCardSynTest {
    private static volatile BankCard bankCardSyn =new BankCard("王五",100);

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                synchronized (BankCardSynTest.class){
                 final BankCard card = bankCardSyn;
                    BankCard newCard = new BankCard(card.getAccountName(), card.getMoney() + 100);
                    System.out.println(newCard);
                    bankCardSyn = newCard;
                }
            }).start();

        }
    }
}
